﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using Ionic.Zip;
using TorchView.PakViewer.Zip;

namespace TorchView.PakViewer
{
    public class PakModel
    {
        private ZipFile _zipFile;
        private ZipTree tree;

        public PakModel(string directory)
        {
            tree = new ZipTree();

            _zipFile = new ZipFile(directory + @"\Pak.zip");
            LoadFiles();
        }

        ~PakModel()
        {
            _zipFile.Dispose();
        }

        public void LoadFiles()
        {
            int count = 0;
            foreach (ZipEntry entry in _zipFile)
            {
                tree.Add(entry);
                ++count;
                //if (count == 10) break;
            }
        }

        public IZipNode Root 
        {
            get
            {
                return tree.Root;
            }
        }
    }
}
